#include <iostream>
#include <string>
using namespace std;

int main()
{
    int a, b;
    cin >> a;
    int count = 0;
    for (int i = 0; i <= a; i++)
    {
        if ((i % 10 == 0) || (i % 10 == 1) || (i % 10 == 5) || (i % 10 == 6))
        {
            long j = i * i;
            string s1 = to_string(i);
            string s2 = to_string(j);
            int pos = s2.size() - s1.size();
            if (s2.find(s1, pos) != -1)
            {
                count++;
            }
        }
    }
    cout << count << endl;
}

